<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN" >
<head>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>报价方案详情</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
<div class="Wrapper">
	<div id="pageInTab" class="pageInTab">
			<div tabid="tabA" title="基本信息" lselected="true">
	            <form id="formSet1">
	                <div class="fieldset1 tabel_col clearFix">
	                	<div class="caption">
	                        <span class="title">基本信息</span>
	                    </div>
	                    <div class="fieldBox col_33">
		                    <div class="label">方案名称</div>
		                    <div class="field">
		                    	<span name="prpsCfgNm" id="prpsCfgNm">&nbsp;</span>
		                    </div>
		                </div>
	                    <div class="fieldBox col_33">
		                    <div class="label">方案政策标准</div>
		                    <div class="field">
		                    	<span name="prpsTypCdNm" id="prpsTypCdNm">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">方案配置编号</div>
		                    <div class="field">
		                    	<span name="prpsCfgNo" id="prpsCfgNo">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">方案产品类型</div>
		                    <div class="field">
		                    	<span name="prpsPrdTypCdNm" id="prpsPrdTypCdNm">&nbsp;</span>
		                    </div>
		                </div>
	                    <div class="fieldBox col_33">
		                    <div class="label">所属事业部</div>
		                    <div class="field">
		                    	<span name="buOrgCdNm" id="buOrgCdNm">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">租赁系数</div>
		                    <div class="field">
		                    	<span name="lsCoe" id="lsCoe">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">有效日期(起)</div>
		                    <div class="field">
		                    	<span name="expStDt" id="expStDt">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">有效日期(止)</div>
		                    <div class="field">
		                    	<span name="expEndDt" id="expEndDt">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">是否允许添加费用项</div>
		                    <div class="field">
		                    	<span name="isAllowAddNm" id="isAllowAddNm">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">是否系统内置</div>
		                    <div class="field">
		                    	<span name="isSysDefNm" id="isSysDefNm">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">支付方式</div>
		                    <div class="field">
		                    	<span name="payWayCdNm" id="payWayCdNm">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">客户保证金处理方式</div>
		                    <div class="field">
		                    	<span name="dpstHdlWayCdNm" id="dpstHdlWayCdNm">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">租赁期数</div>
		                    <div class="field">
		                    	<span name="lsPd" id="lsPd">&nbsp;</span>
		                    	<span name="lsPdUntCdNm" id="lsPdUntCdNm">&nbsp;</span>
		                    </div>
		                </div>
		                <div class="fieldBox col_33">
		                    <div class="label">租赁期满处理方式</div>
		                    <div class="field">
		                    	<span name="expHdlWayCdNm" id="expHdlWayCdNm">&nbsp;</span>
		                    	<input name=prpsCfgId id="prpsCfgId" type="hidden" value="${id }">
		                    </div>
		                </div>
		                <div class="caption">
				            <span class="title">详细信息</span>
				        </div>
				        <div class="fieldBox col_100">
				            <div class="sqPanel">
				                <div class="sqPanel_head inL">
				                    <span>相关费用</span>
				                </div>
				                <div class="sqPanel_body">
				                    <div id="ligergrid_fee" class="sq-grid"></div>
				                </div>
				            </div>
				        </div>
	                </div>
	            </form>
		</div>
		<div tabid="tabB" title="配置属性">
            <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
        </div>
		<div tabid="tabC" title="年利率配置">
            <iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
        </div>
		<div tabid="tabD" title="融资返利比例配置">
            <iframe frameborder="0" name="tabD" id="tabD" src=""></iframe>
        </div>
		<div tabid="tabE" title="手续费比例配置">
            <iframe frameborder="0" name="tabE" id="tabE" src=""></iframe>
        </div>
	</div>
</div>

<script type="text/javascript">
var feeGrid;//相关费用信息
var loadedTabs=[];
var gpsRebBscPct = "";
var gpsRebBscPc = "";
var lsRebBscPct = "";

$(function(){

	$('#formSet1').ligerForm({
        validate : true
	});

	//费用类型
	var feeTypCdListJSON = [];
    <c:if test="${not empty feeTypCdListJSON}"> feeTypCdListJSON = ${feeTypCdListJSON}; </c:if>
    //费用计算基数
	var calBaseCdListJSON = [];
    <c:if test="${not empty calBaseCdListJSON}"> calBaseCdListJSON = ${calBaseCdListJSON}; </c:if>
    //费用计入方式
	var cntWayCdListJSON = [];
    <c:if test="${not empty cntWayCdListJSON}"> cntWayCdListJSON = ${cntWayCdListJSON}; </c:if>
    //是否
	var yesOrNoCdListJSON = [];
    <c:if test="${not empty yesOrNoCdListJSON}"> yesOrNoCdListJSON = ${yesOrNoCdListJSON}; </c:if>
	feeGrid = $("#ligergrid_fee").ligerGrid({
        url: '<%=path%>/project/prjQuatPrpsCfgD/initList.do',
        method: 'get',
        columns: [
            {display: '费用类型', name: 'feeTypCd', minWidth: 80,
                editor: {
                    type: 'select',
                    data: feeTypCdListJSON,
                    valueField: 'code',
                    textField: 'codeNm'
                },
                valueField: 'feeTypCd',
                textField: 'feeTypCdNm',
                render: function (item) {
                    return item.feeTypCdNm;
                }
            },
            {display: '比例(下限)', name: 'feePctMin', minWidth: 80, type: 'numberbox',align: 'right',
            	editor: {type: 'text'}
            },
            {display: '比例(上限)', name: 'feePctMax', minWidth: 80, type: 'numberbox',align: 'right',
            	editor: {type: 'text'}
            },
            {display: '计算基数', name: 'calBaseCd', minWidth: 80,
            	editor: {
                    type: 'select',
                    data: calBaseCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'calBaseCd',
                textField: 'calBaseCdNm',
                render: function (item) {
                    return item.calBaseCdNm;
                }
            },
            {display: '是否固定金额', name: 'isFixedAmt', minWidth: 80,
            	editor: {
                    type: 'select',
                    data: yesOrNoCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'isFixedAmt',
                textField: 'isFixedAmtNm',
                render: function (item) {
                    return item.isFixedAmtNm;
                }
            },
            {display: '固定金额', name: 'fixedAmt', minWidth: 80, type: 'numberbox',align: 'right',
            	editor: {type: 'text'}
            },
            {display: '计入方式', name: 'cntWayCd', minWidth: 80,
            	editor: {
                    type: 'select',
                    data: cntWayCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'cntWayCd',
                textField: 'cntWayCdNm',
                render: function (item) {
                    return item.cntWayCdNm;
                }
            },
            {display: '是否系统内置', name: 'isSysDef', minWidth: 80,
            	editor: {
                    type: 'select',
                    data: yesOrNoCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'isSysDef',
                textField: 'isSysDefNm',
                render: function (item) {
                    return item.isSysDefNm;
                }
            },
            {display: '是否允许变更', name: 'isAllowChg', minWidth: 80,
            	editor: {
                    type: 'select',
                    data: yesOrNoCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'isAllowChg',
                textField: 'isAllowChgNm',
                render: function (item) {
                    return item.isAllowChgNm;
                }
            },
            {display: '是否缺省显示', name: 'isDefVis', minWidth: 80,
            	editor: {
                    type: 'select',
                    data: yesOrNoCdListJSON,
                    valueField: 'key',
                    textField: 'value'
                },
                valueField: 'isDefVis',
                textField: 'isDefVisNm',
                render: function (item) {
                    return item.isDefVisNm;
                }
            }
        ],
        onBeforeEdit: function (e) {
        	e.column.editor.readonly = true;
        },
        usePager: false,
        root: 'rows',
        record: 'total',
        hideLoadButton: true,
        width: '100%',
        height: 300,
        heightDiff: -2,
        enabledEdit: true,
        isScroll: false,
        //checkbox: true,
        rownumbers: true,
        allowUnSelectRow: true,
        alternatingRow: false
    });
	initTab();
	initData();
});

		function initData(){
			var id = $("#prpsCfgId").val();
			if(!id){
				return;
			}
	    	var _url = '<%=path%>/project/prjQuatPrpsCfgM/getById.do';
	    	$.ajax({
	    		type: 'get',
	    		dataType:'json',
	    		data:{id:id},
	    		url: _url,
	    		success:function(msg){
	    			 if(msg.success == 1){
	    				 setData(msg.data);//设置数据
	    				 var _prpsCfgId = $("#prpsCfgId").val();
    				     if(_prpsCfgId){
    				    	feeGrid.setParm("prpsCfgId", _prpsCfgId);
    				    	feeGrid.reload();
    				     }
	    			 }else{
	    				 $.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
	    			 }
	    		}
	    	});
    	}
		
		//设置页面数据
	    function setData(data){
	    	if(data.gpsRebBscPct){
				gpsRebBscPct = data.gpsRebBscPct;
			}
			if(data.gpsRebBscPc){
				gpsRebBscPc = data.gpsRebBscPc;
			}
			if(data.lsRebBscPct){
				lsRebBscPct = data.lsRebBscPct;
			}
	    	var form = liger.get("formSet1");
	    	$("#prpsCfgNm").html(data.prpsCfgNm);
	    	$("#prpsCfgNo").html(data.prpsCfgNo);
	    	$("#prpsPrdTypCdNm").html(data.prpsPrdTypCdNm);
	    	$("#prpsTypCdNm").html(data.prpsTypCdNm);
	    	$("#buOrgCdNm").html(data.buOrgCdNm);
	    	$("#lsCoe").html(data.lsCoe);
	    	$("#isAllowAddNm").html(data.isAllowAddNm);
	    	$("#isSysDefNm").html(data.isSysDefNm);
	    	$("#payWayCdNm").html(data.payWayCdNm);
	    	$("#dpstHdlWayCdNm").html(data.dpstHdlWayCdNm);
	    	$("#lsPd").html(data.lsPd);
	    	$("#lsPdUntCdNm").html(data.lsPdUntCdNm);
	    	$("#expHdlWayCdNm").html(data.expHdlWayCdNm);
	    	
	    	//日期处理
	    	if(data.expStDt){
	    		var date = new Date(data.expStDt);
	    		var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
	    		$("#expStDt").html(dateStr);
	    	}
	    	if(data.expEndDt){
	    		var date = new Date(data.expEndDt);
	    		var dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
	    		$("#expEndDt").html(dateStr);
	    	}
	    	
		};

		//初始化Tab页
	    function initTab(){
	    	pageInTab = $("#pageInTab").ligerTab({
	            height: 'auto',
	            contextmenu: false,
	            minIframeHeight: 450,
	            onBeforeSelectTabItem: function (tabid) {
	            	var _prpsCfgId = $("#prpsCfgId").val();
	            	if(tabid!="tabA"){
		                if(!_prpsCfgId){
		                	top.$.ligerDialog.SQalert({content: "请确认报价方案基本信息已存在", SQ_type: "warning"});
		                	return false;
		                }
	            	}
	            },
	            onAfterSelectTabItem: function(tabid) {
	                if (loadedTabs.indexOf(tabid)<0) {
	                	var _prpsCfgId = $("#prpsCfgId").val();
	                	if(tabid!="tabA"){
		                	if(!_prpsCfgId){
		                		 top.$.ligerDialog.SQalert({content: "请确认报价方案基本信息已存在", SQ_type: "warning"});
		                         return false; 
		                	}
	                	}
	                    loadedTabs.push(tabid);
	                    switch (tabid){
	                        case "tabB":
	                            pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjQuatPrpsAttr/toDetailPage.do?prpsCfgId="+_prpsCfgId);
	                            break;
	                        case "tabC":
	                            pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjQuatPrpsCfgAi/toDetailListPage.do?prpsCfgId="+_prpsCfgId);
	                            break;
	                        case "tabD":
	                            pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjQuatPrpsReb/toListPage.do?isDetail=1&prpsCfgId="+_prpsCfgId+"&gpsRebBscPct="+gpsRebBscPct+"&gpsRebBscPc="+gpsRebBscPc+"&lsRebBscPct="+lsRebBscPct);
	                            break;
	                        case "tabE":
	                            pageInTab.setTabItemSrc(tabid, "<%=path%>/project/prjQuatPrpsReb/toListPage2.do?isDetail=1&prpsCfgId="+_prpsCfgId);
	                            break;
	                    }
	                };
	                SetIframe_height();
	            }
	        });

	        /* $.extend(true, pageInApp, {
	            pageInTab: pageInTab
	        }); */
	    };
</script>



</body>
</html>
